<template>
  <view class="js-operationPswInput">
    <u-popup
      v-model="visibleSync"
      mode="center"
      border-radius="30"
      closeable
      width="90%"
      close-icon="close-circle"
      close-icon-color="#cccccc"
      close-icon-size="42"
      @close="closePopup"
    >
      <view class="popup-container">
        <view class="popup-title">请输入操作密码</view>
        <view class="popup-content ">
          <view class="popup-message-input">
            <u-message-input
              mode="box"
              :maxlength="6"
              :focus="true"
              boxBgColor="#49494D"
              @change="messageChange"
              @finish="messageFinish"
            >
            </u-message-input>
          </view>
          <view
            class="popup-forgetPsw"
            @click="navigateTo('/pages/my/setOperationPassword')"
          >忘记密码？</view>
        </view>
      </view>
    </u-popup>
  </view>
</template>

<script>
import service from '@/common/service.js';
import util from '@/common/utils';

export default {
  props: { show: { type: Boolean, default: false } },
  data() {
    return { visibleSync: false };
  },
  watch: {
    show: {
      handler(newVal, oldVal) {
        this.visibleSync = newVal;
      },
      immediate: true,
      deep: true
    }
  },
  onLoad() {},
  methods: {
    showPopup() {
      this.visibleSync = true;
    },
    closePopup() {
      this.visibleSync = false;
      this.$emit('update:show', false);
    },
    messageChange(e) {
      this.$emit('messageChange', e);
    },
    messageFinish(e) {
      this.$emit('messageFinish', e);
    },
    navigateTo(url) {
      uni.navigateTo({
        url: url
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.js-operationPswInput {
  width: 100%;
}

.popup-container {
  width: 100%;
  padding: 50rpx 40rpx;
  background-color: #313133;
  .popup-title {
    font-size: 32rpx;
    font-weight: bold;
    color: #ffffff;
    text-align: center;
    background: linear-gradient(
      0deg,
      #f0c4f0 0%,
      #e7ecef 51.513671875%,
      #aee4ff 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  .popup-content {
    margin-top: 46rpx;
    width: 100%;
    padding: 0;
    .popup-message-input {
      position: relative;
      width: 100%;
    }
    .popup-forgetPsw {
      margin-top: 50rpx;
      width: 100%;
      line-height: 1;
      font-size: 28rpx;
      font-weight: normal;
      color: #999999;
      text-align: center;
    }
  }
}
</style>
